home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts36-04
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: API's
- Date: Sun, 03 Mar 96 05:33:50 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4hbavm$6d8@sam.inforamp.net>
- References: <BMagnusson-2802961627410001@204.118.152.122>
- NNTP-Posting-Host: ts36-04.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <BMagnusson-2802961627410001@204.118.152.122>,
- BMagnusson@PrecisionImages.com (Baiss E. Magnusson) wrote:
- >I have developed API's for our video capture products and I am considering
- >changing the design to support functions which may/may not reside in the
- >image processor on our PCI video image capture board.
- >
- >Does anyone know why it is a good/bad idea to use a variable number of
- >parameters in C function calls which are part of an API?
-
- I'm no video capture guru and I did not consider the first paragraph of your
- posting when I wrote this reply. Hopefully, my ignorance doesn't matter. But
- you have several choices. Your choice will depend on your implementation.
- I'll enumerate some of my thoughts, but you'll have to implement them and
- debug them.
-
- 1. Define some header macros where
- f(x) = f1(x)
- f(x,x1) = f2(x,x1)
- f(x,x1,x2) = f2(x,x1,x2)
- etc.
- This will not work where the amount of parameters is unlimited. Or the types
- of parameters make the macros too cumbersome.
-
- 2. Use C++'s ability to have a function with several sets of parameters.
- You'd have to export a class API in this case.
-
- 3. Use C++'s ability to overload operators. Instead of using
- f(x,x1,x2,..,xn)
- use
- f << x << x1 << x2 << .. << xn
- But don't limit yourself to the << operator. Then following will also work.
- f + x + x1 + x2 + .. + xn
- This method is quite hard to visualize and implement.
-
- 4. Use the same calling procedure as the printf commands...
- int printf(const char *format[, argument, ...]);
- Obsolete, but easier for conventional C programmers.
-
- I hope this helps.
-
- Agrivar
-